import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: { /* 1、狀態 */
    letter:"",
    city:localStorage.getItem("city") || "武汉"
  },
  mutations: {  /* 3、變化 */
    changeLetter(state,letter){
      state.letter = letter;
    },
    changeCity(state,city){
      localStorage.setItem("city",city)
      state.city = city;
    }
  },
  actions: {  /* 2、動作 */
   /*  changeLetter(ctx,letter){
      ctx.commit("changeLetter",letter)
    } */
  }
})
